\defmodule{ShiftedMathFunction}

Represents a function computing $f(x) - \delta$ for a user-defined function
$f(x)$ and shift $\delta$.

\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        ShiftedMathFunction
 * Description:  
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       Éric Buist
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.functions;\begin{hide}

\end{hide}

public class ShiftedMathFunction implements MathFunction\begin{hide}

,
      MathFunctionWithFirstDerivative, MathFunctionWithDerivative,
      MathFunctionWithIntegral {
   MathFunction func;
   double delta;
\end{hide}

   public ShiftedMathFunction (MathFunction func, double delta)\begin{hide} {
      if (func == null)
         throw new NullPointerException ();
      this.func = func;
      this.delta = delta;
   }\end{hide}
\end{code}
\begin{tabb}   Constructs a new function shifting the function \texttt{func} by
 a shift \texttt{delta}.
\end{tabb}
\begin{htmlonly}
   \param{func}{the function.}
   \param{delta}{the shift.}
\end{htmlonly}
\begin{code}

   public MathFunction getFunction ()\begin{hide} {
      return func;
   }\end{hide}
\end{code}
\begin{tabb}   Returns the function $f(x)$.
\end{tabb}
\begin{htmlonly}
   \return{the function.}
\end{htmlonly}
\begin{code}

   public double getDelta ()\begin{hide} {
      return delta;
   }\end{hide}
\end{code}
\begin{tabb}   Returns the shift $\delta$ = \texttt{delta}.
\end{tabb}
\begin{htmlonly}
   \return{the shift.}
\end{htmlonly}
\begin{code}\begin{hide}

   public double evaluate (double x) {
      return func.evaluate (x) - delta;
   }

   public double derivative (double x) {
      return MathFunctionUtil.derivative (func, x);
   }

   public double derivative (double x, int n) {
      return MathFunctionUtil.derivative (func, x, n);
   }

   public double integral (double a, double b) {
      return MathFunctionUtil.integral (func, a, b) - (b - a)*getDelta();
   }
}\end{hide}
\end{code}
